package main

import (
	"fmt"
	"time"
)

func main() {
	ch := make(chan float32, 4)
	for i := 0; i < cap(ch); i++ {
		ch <- 1.0 //写通道
	}
	for len(ch) > 0 {
		value := <-ch //读通道
		fmt.Println(value)
	}

	ch1 := make(chan int, 3)

	go func() {
		time.Sleep(3 * time.Second)
		ch1 <- 1
		ch1 <- 2
		fmt.Println("写入ch1")
	}()

	value1 := <-ch1
	value1 = <-ch1
	time.Sleep(5 * time.Second)
	fmt.Println("退出, value1:", value1)
}
